import request from '@/utils/request'


export default{
    getUserList(searchModel){
        return request({
            url:'/users',
            method:'get',
            params:{
                name: searchModel.name,
                enrollmentYear: searchModel.enrollmentYear,
                faculty:searchModel.faculty,
                pageNo: searchModel.pageNo,
                pageSize: searchModel.pageSize
            }
        });
    },
    deleteImage(fileName) {
        return request({
            url: `/files/${fileName}`,   // 调用后端的删除接口
            method: 'delete',
        });
    },
    addUser(user){
        return request({
            url: '/users',
            method: 'post',
            data: user
        });
    },
    updateUser(user){
        return request({
            url: '/users',
            method: 'put',
            data: user
        });
    },
    getUserById(id){
        return request({
            url: `/users/${id}`,
            method: 'get',
        });
    },
    saveUser(user){
        if(user.id == null || user.id == undefined){
            return this.addUser(user);
        }else{
            console.log(user)
            return this.updateUser(user);
        }
    },
    deleteUserById(id){
        return request({
            url: `/users/${id}`,
            method: 'delete',
        });
    },
}